<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	template="/template/template.xhtml">

	<ui:define name="center">
		<f:event type="preRenderView" listener="#{connexionManagedBean.checkConnected}" />
		<p:panel id="panierPanel" header="Votre Panier">
			<h:form id="panierForm" rendered="#{orderManagedBean.panier.size() gt 0}">
				<p:dataTable id="panierTable" var="book" value="#{orderManagedBean.panierKeys}">
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{msg['panier.column.title.header']}" />
						</f:facet>
						<h:outputText value="#{book.title}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{msg['panier.column.quantity.header']}" />
						</f:facet>
						<h:outputText value="#{orderManagedBean.panier[book]}" />
						<p:commandButton ajax="true" action="#{orderManagedBean.moreQuantityOfBook(book)}" value="+" update=":panierPanel" />
						<p:commandButton ajax="true" action="#{orderManagedBean.lessQuantityOfBook(book)}" value="-" update=":panierPanel" />
						<p:commandButton ajax="true" action="#{orderManagedBean.removeBook(book)}" value="T" update=":panierPanel" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Prix Unitaire " />
						</f:facet>
						<h:outputText value="#{book.price}" />
					</p:column>
				</p:dataTable>
				<h:outputLabel value="Total: " />
				<h:outputText value="#{orderManagedBean.totalOrder()}" />
				<br />
				<br />
				<c:if test="#{connexionManagedBean.connected}">
					<p:commandButton action="#{orderManagedBean.save}" value="Commander" ajax="false" />
				</c:if>
				<c:if test="#{!connexionManagedBean.connected}">
					<h:outputText value="Connectez vous pour passer la commande" />
				</c:if>
			</h:form>
			<h:outputText value="Votre panier est vide." rendered="#{orderManagedBean.panier.size() eq 0}" />
		</p:panel>

	</ui:define>

</ui:composition>